import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/index.vue'
import Home from '../views/Home/Index.vue'

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'Home',
        component: Home,
        meta: {
          title: '首页',
          icon: 'Home',
          isMenu: true
        }
      },
      {
        path: 'cloudGaming',
        name: 'CloudGaming',
        component: () => import('../views/CloudGaming/Index.vue'),
        meta: {
          title: '云游戏',
          icon: 'CloudGaming',
          isMenu: true
        }
      },
      {
        path: 'cloudGaming/searchResults',
        name: 'SearchResults',
        component: () => import('../views/CloudGaming/SearchResults.vue'),
        meta: {
          title: '搜索结果',
          icon: 'SearchResults'
        }
      },
      {
        path: 'cloudGaming/detail/:gameId',
        name: 'GameDetail',
        component: () => import('../views/CloudGaming/GameDetail.vue'),
        meta: {
          title: '游戏详情',
          icon: 'CloudGaming'
        }
      },
      {
        path: 'cloudComputer',
        name: 'CloudComputer',
        component: () => import('../views/CloudComputer/Index.vue'),
        meta: {
          title: '云电脑',
          icon: 'CloudComputer',
          isMenu: true
        }
      },
      {
        path: 'welfareCenter',
        name: 'WelfareCenter',
        component: () => import('../views/WelfareCenter/Index.vue'),
        meta: {
          title: '福利中心',
          icon: 'WelfareCenter',
          isMenu: true
        }
      },
      // {
      //   path: 'downloadAccelerator',
      //   name: 'DownloadAccelerator',
      //   component: () => import('../views/DownloadAccelerator/Index.vue'),
      //   meta: {
      //     title: '下载加速器',
      //     icon: 'DownloadAccelerator'
      //   }
      // },
      // {
      //   path: 'gameTrainer',
      //   name: 'GameTrainer',
      //   component: () => import('../views/GameTrainer/Index.vue'),
      //   meta: {
      //     title: '游戏修改器',
      //     icon: 'GameTrainer'
      //   }
      // }
    ]
  },
  // {
  //   path: '/login',
  //   name: 'Login',
  //   component: () => import('../views/Login.vue'),
  //   meta: {
  //     title: '登录'
  //   }
  // }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  document.title = to.meta.title || 'Vue3 Element Admin'
  next()
})

export default router